var gulp = require('gulp'),
    gutil = require('gulp-util'),
    uglify = require('gulp-uglify'),
    concat = require('gulp-concat'),
    minifyCss = require("gulp-minify-css"),
    jshint = require("gulp-jshint");
var imagemin = require('gulp-imagemin');
//var pngquant = require('imagemin-pngquant'); //png图片压缩插件

gulp.task('jsLint', function () {
    gulp.src('./public/script/*.js')
        .pipe(jshint())
        .pipe(jshint.reporter()); // 输出检查结果
});

gulp.task('js', function() {
    gulp.src('./public/script/*.js')
        .pipe(uglify())
        .pipe(concat('all.js'))
        .pipe(gulp.dest('./public/dist/js'));
});

gulp.task('css', function() {
    gulp.src('./public/stylesheets/*.css')
        .pipe(minifyCss()) //压缩css
        .pipe(gulp.dest('./public/dist/css'));
});


gulp.task('image', function() {
    gulp.src('./public/images/*/*')
        .pipe(imagemin({
            progressive: true,
            //use: [pngquant()] //使用pngquant来压缩png图片
        }))
        .pipe(gulp.dest('./public/dist/imgs'));
});

// 定义默认任务
gulp.task('default', ['jsLint','js','css','image']);